Shell

推荐列表 站点导航

当前位置:首页 > 脚本编程 > Shell >

php URL rewrite路径重写一例

来源:互联网  作者:网友投稿  发布时间:2021-01-11 03:39
为大家介绍一个php url rewrite路径重写的例子,有需要的朋友,可以参考下。...

一、文件 test.php
 

复制代码 代码示例:

<?php
$id=$_GET["id"];
echo $id;
?>

首先 apache文件里

打开Apache配置文件httpd.conf,找到如下:#LoadModule rewrite_module modules/mod_rewrite.so

开启rewrite,去点前面"#"

二、重载Allowoverride
查找apache配置文件找到如下:
 

复制代码 代码示例:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

将AllowOverride None 改为 AllowOverride All

在htaccess中暂时了解到三种url重定义
 

复制代码 代码示例:

<IFMODULE mod_rewrite.c>
RewriteEngine On
#RewriteBase /  (若文件在根目录下不必定义)
#RewriteRule ^t_(.*).html$ test.php?id=$1 [NC](打开test.php以t_id.html  比如 t_2.html  页面输出 id=2)
RewriteRule ^([0-9]+)$ test.php?id=$1 [NC](直接输入id  比如 localhost/test/2  页面输出 id=2)
RewriteRule ^index.html$ index.php [NC](直接输入index.html可打开index.php这个页面)
</IFMODULE>

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/shell/12324.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

php URL rewrite路径重写一例

2021-01-11 编辑:网友投稿

一、文件 test.php
 

复制代码 代码示例:

<?php
$id=$_GET["id"];
echo $id;
?>

首先 apache文件里

打开Apache配置文件httpd.conf,找到如下:#LoadModule rewrite_module modules/mod_rewrite.so

开启rewrite,去点前面"#"

二、重载Allowoverride
查找apache配置文件找到如下:
 

复制代码 代码示例:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

将AllowOverride None 改为 AllowOverride All

在htaccess中暂时了解到三种url重定义
 

复制代码 代码示例:

<IFMODULE mod_rewrite.c>
RewriteEngine On
#RewriteBase /  (若文件在根目录下不必定义)
#RewriteRule ^t_(.*).html$ test.php?id=$1 [NC](打开test.php以t_id.html  比如 t_2.html  页面输出 id=2)
RewriteRule ^([0-9]+)$ test.php?id=$1 [NC](直接输入id  比如 localhost/test/2  页面输出 id=2)
RewriteRule ^index.html$ index.php [NC](直接输入index.html可打开index.php这个页面)
</IFMODULE>

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/shell/12324.shtml

相关文章

风云图片

推荐阅读

返回Shell频道首页